<!--<?php
require_once template('header'); 
print <<<EOT
<!-- 右边开始 -->
<script language="javascript">
$(function(){
get_ship();
//其他收货地址
$("#use_other").click(function(e){
$("#other_address").toggle();
});
//配送方式
$("#province").change(function(e){
get_ship();
});
$("#city").change(function(e){
get_ship();
});
//地址选择
$("input[@name=con_address][@type=radio]").click( function () { 
$.getJSON(
    "ajax.php?action=address&date=$m_now_time&add_id="+$('input[@name=con_address][@checked]').val(),
    function(json){
    $("#consignee").attr("value",json.consignee);
    $("#email").attr("value",json.email);
    $("#phone").attr("value",json.tel);
    $("#mobile").attr("value",json.mobile);
    $("#province").attr("value",json.province);
    initcity();
    $("#city").attr("value",json.city);
    $("#address").attr("value",json.address);
    $("#zipcode").attr("value",json.zipcode);
     get_ship();
    })
}); 

//提交订单
$("#submit_pay").click(function(e){
var msg='';
if($('#consignee').val().length<2){
   msg += user_msg['buyer_name'] +  '\<br/>';
}
if ($('#phone').val().length < 7) {
   msg += user_msg['buyer_tel_err'] + '\<br/>';
}
var myReg = /^[-a-zA-Z0-9_\.]+@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,5}$/;
    if(!myReg.test($('#email').val())){
		 msg += user_msg['login_email'] + '\<br/>';
	}
if($('#address').val().length < 1 || $('#province').val().length<1 || $('#city').val().length<1 ){  
   msg += user_msg['buyer_address'] + '\<br/>';
}
if($('#zipcode').val().length < 5){
     msg += user_msg['buyer_zip'] + '\<br/>';
}
if (msg.length > 0){
$('#other_address').show();
}
if(!$('input[@name=area_id][@checked]').val()){
   msg += user_msg['buyer_area'] + '\<br/>';
}
if(!$('input[@name=pay_id][@checked]').val()){
   msg += user_msg['buyer_pay'] + '\<br/>';
}
if($('input[@name=is_invoice][@checked]').val() && $('#invoice').val()==''){
     msg += user_msg['buyer_invoice'] + '\<br/>';
}
if (msg.length > 0){
       $("#alert_msg").html(msg);
       $.blockUI({ message: $('#question'), css: { width: '275px' } });
       $('#yes').click(function() {
            $.unblockUI();
         });
         $('#no').click(function() {
            $.unblockUI();
         });
        return false;
}
$('#pay_cart').block({ 
                message: '<h1><img src="images/admincp/busy.gif" /> Loading...</h1>', 
                css: { backgroundColor: '#f1f1f1', color: '#f60' } 
            });
$.ajax({
   type: "POST",
   url: "cart.php?action=pay",
   cache:false,
   data: $('#pay_form :input').serialize(),
   success: function(msg){
     $("#pay_cart").html(msg);
   },
   complete: function() {
     // unblock when remote call returns
     $.unblockUI();
   }
});
});

//订单总计
var ship_price = 0.00;
var pack_price = 0.00;
var cess_price = 0.00;
var goods_price = parseFloat($rowset->total_price); 
$("#ship_cart").click(function(e){
//运 费
if($('input[@name=area_id][@checked]').val()){
$.getJSON("ajax.php?action=ship_price&total_kg=$rowset->total_kg&total_price=$rowset->total_price&date=$m_now_time&area_id="+$('input[@name=area_id][@checked]').val(),
function(json){
ship_price = parseFloat(json);
$("#ship_price").html('+ $lang[buy_shipping]:'+currency(ship_price));
$("#order_price").html('= $lang[buy_payall]:'+(currency(goods_price+ship_price+pack_price+cess_price)));
});
}
});

$("#pack_cat").click(function(e){
//包装
if($('input[@name=casing_id][@checked]').val()){
$.getJSON("ajax.php?action=pack_price&total_price=$rowset->total_price&date=$m_now_time&casing_id="+$('input[@name=casing_id][@checked]').val(),
function(json){
pack_price = parseFloat(json);
$("#pack_price").html('+ $lang[buy_warshipping]:'+currency(pack_price));
$("#order_price").html('= $lang[buy_payall]:'+(currency(goods_price+ship_price+pack_price+cess_price)));
});
}
});
//税率
$("#is_invoice").click(function(e){
if($('input[@name=is_invoice][@checked]').val()){
     cess_price = parseFloat(goods_price*$mm_cess);
     $("#cess_price").html('+ $lang[cess_price]:'+currency(cess_price));
}else{
    cess_price = parseFloat(0.00);
    $("#cess_price").empty();
}
$("#order_price").html('= $lang[buy_payall]:'+(currency(goods_price+ship_price+pack_price+cess_price)));
$("#temp").load("ajax.php?action=cess&date=$m_now_time"+'&cess_price='+cess_price);
});
});

//货币符号替换
function currency(price){
    var mm_price_length = $mm_price_length;
    var mm_price_sign   = '$mm_price_sign';
    if(mm_price_length==1){
     return  mm_price_sign + price.toFixed(2);
    }else{
     return   mm_price_sign+price;
    }
}

function get_ship(){
    $.getJSON(
    "ajax.php",
    {action:"ship",kg:$rowset->total_kg,price:$rowset->total_price,province:$('#province').val(),city:$('#city').val(),rand:Math.random()},
    function(json){
    if(json==''){
    alert('该地区没有配送方式');
    return false;
    }
    $("#ship_cart").html('<dt>$lang[buy_delivery]</dt>');
    $.each(json,function(i){
    $('#ship_cart').append("<dd><input type='radio' name='area_id'  value='"+json[i].area_id+"'>"+json[i].name +"：您选择的是"+json[i].ship_desc+" 将产生运费<strong> "+json[i].exes+" </strong> 谢谢! </dd>");
    })
    })
}
</script> 
<tr><td width="100%">
		<div class="member_xg">
			<div class="title8"><span>$lang[buy_payorder]</span></div>
			<fieldset>
				<legend>$lang[cart_text]</legend>
				<table cellpadding="0" cellspacing="1" class="ca4">
                  	<tr>	  	
						<th width="200">$lang[buy_name]</th>
						<th>$lang[attribute]</th>  
						<th>$lang[buy_price]</th>
						<th>$lang[kg]</th>
						<th width="120">$lang[buy_nums]</th>
						<th>共 计</th>
                  	</tr>
<!--
EOT;
foreach ($cart_rt as $val){
print <<<EOT
-->
                  	<tr>
						<td class="td1"><a href="$val[url]" title="$val[title]">$val[subject]<span style="cursor:pointer;"><img src="$val[photo]" /></span></a></td>
						<td>&nbsp;$val[goods_att]</td>
						<td>$val[price]</td>
                    	<td>$val[kg] kg</td>
					    <td>$val[cart_num]</td>
					      <td>$val[total_price]</td>
					</tr>
<!--
EOT;
} print <<<EOT
-->
					
				</table>
			<p id="cat_count" >$lang[goods_nums]:$sum_cart[nums] $lang[buy_goods]:$goods_price <span id="ship_price"></span>  <span id="pack_price"></span>  <span id="cess_price"> </span> <span id="order_price"></span></p>
			</fieldset>
			
			<div id="pay_cart">
			<form  method="post"  name="pay_form" id="pay_form">
			<fieldset class="cat1">
				<legend>$lang[payusernamea] </legend>
<!--
EOT;
foreach ($member_address  as $val){
print <<<EOT
-->	
				<p class="cart5"><input type="radio" name="con_address"  id="con_address" value="$val[id]" $val[checked] />$val[province] $val[city] $val[address]</p>
<!--
EOT;
} print <<<EOT
-->	
				<p class="cart5" style="margin-top:10px;"><a href="member.php?action=address" style="float:right;padding-left:8px;padding-right:8px;" class="btn2">$lang[admin] $lang[buyer_add]</a>
<a href="javascript:;" id="use_other" style="float:left;padding-left:8px;padding-right:8px;" class="btn2">$lang[new_address]</a></p>
				<div id='other_address' style="display: $disp">	
				<table cellpadding="0" cellspacing="5" class="cat8">
                  	<tr>
						<th>$lang[buyer_name]</th>
						<td><input type="text" name="consignee" id="consignee" class="inp" size="30" value="$consignee"/></td>
						<th>$lang[buyer_email]</th>
						<td><input type="text" name="email" id="email" class="inp" size="50" value="$email"/></td>
					</tr>
					<tr>
						<th>$lang[tel]</th>	
						<td><input type="text" name="phone" id="phone" class="inp" size="30" value="$tel" maxlength="15"/></td>
						<th>$lang[telb]</th>
						<td><input type="text" name="mobile" id="mobile" class="inp" size="30" value="$tel" maxlength="15"/></td>
					</tr>
					<tr>
						<th>$lang[buyer_add]</th>
						<td colspan="3">
						<script src="include/javascript/initcity.js"></script>
						<select onchange="initcity();" id="province" name="province">
						<script>creatprovince('$province');</script>
						</select>
						<select name="city" id="city"><script>initcity('$city');</script></select>
					    &nbsp;<input name="address" type="text" class="inp" style="width:150px;" id="address" value="$address" maxlength="200" /></td>
					</tr>
					<tr>
						<th>$lang[user_zip]</th>
						<td colspan="3">
						<input type="text" name="zipcode" id="zipcode" value="$zipcode"class="inp" size="8" />
						</td>
					</tr>
				</table>
				</div>
			</fieldset>
			
		<fieldset class="cat2">
				<legend>$lang[buy_paydelsel]</legend>
				<dl id="ship_cart">					
				</dl>
				<dl id="pack_cat">
					<dt>$lang[buy_wrapping]</dt>
<!--
EOT;
foreach ($wrapping as $val){
print <<<EOT
-->
					<dd><input type="radio" name="casing_id" value="$val[id]" /> $val[name]：<strong>$val[price]</strong>,$val[desc] $val[photo]</dd>
<!--
EOT;
} print <<<EOT
-->
				</dl>	
			</fieldset>
			
			<fieldset class="cat2">
				<legend>$lang[buy_zxzffs]</legend>
				<dl>
				
					<dt>$lang[buy_pay]</dt>
<!--
EOT;
foreach ($payment as $val){
print <<<EOT
-->
<dd><input type="radio" name="pay_id" value="$val[id]"> $val[name] $val[pay_desc]</dd>
<!--
EOT;
} print <<<EOT
-->
				</dl>
			</fieldset>

			<fieldset class="cat1">
				<legend>$lang[other_msg]</legend>

				<dl>
					<dt>$lang[invoice] </dt>
					<dd><input name="invoice" id="invoice" type="text" class="inp"/> <input name="is_invoice"  id="is_invoice" type="checkbox" value="1"/> $lang[is_invoice]</dd>
				</dl>
			
				<dl>
					<dt><span class="dod8">$lang[annotation]</span></dt>
					<dd><textarea name="buyer_main" cols="" rows="5" class="inp2" id="buyer_main">$buyer[main]</textarea></dd>
				</dl>
			</fieldset>
			
			<p class="ca6" style="margin:10px 20px;"><a href="javascript:;" id="submit_pay"><img src="$imgpath/cart.gif"></a></p>
</form>		
		</div>
		<div class="title_b"><p></p></div>
</div>
<!-- 右边结束 -->
<!--
EOT;
?>-->